package com.example.admin.controller;

import com.example.admin.pojo.AddChannel;
import com.example.admin.service.AdChannelService;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/ad_chanel/v1")
@Api(tags = "频道接口说明")
public class AdChannelController {
    @Autowired
    AdChannelService adChannelService;
    
    
    /**
     * 得到所有广告频道
     *
     * @param channelDto 频道dt
     */
    @ApiOperation(notes = "查询、分页和展示",value = "查询、分页和展示")
    @PostMapping("/get_all_ad_channel")
    public ResponseResult getAllAdChannel(@RequestBody ChannelDto channelDto){
        List<AdChannel> adChannelAll = adChannelService.getAdChannelAll(channelDto);
        return ResponseResult.okResult(adChannelAll);
    }
    
    
    /**
     * 删除广告频道
     *
     * @param id id
     */
    @ApiOperation(notes = "删除（逻辑）",value = "删除（逻辑）")
    @PostMapping("/delete_ad_channel")
    public ResponseResult deleteAdChannel(Integer id){
        return adChannelService.deleteAdChannel(id);
    }
    

    /**
     * 添加广告频道
     *
     * @param addChannel 添加频道
     */
    @ApiOperation(notes = "添加频道",value = "添加频道")
    @PostMapping("/add_ad_channel")
    public ResponseResult addAdChannel(@RequestBody AddChannel addChannel){
        return adChannelService.addAdChannel(addChannel);
    }
    
    
    /**
     * 修改广告频道
     *
     * @param addChannel 添加频道
     */
    @ApiOperation(notes = "修改频道",value = "修改频道")
    @PostMapping("/edit_ad_channel")
    public ResponseResult editAdChannel(@RequestBody AddChannel addChannel){
        return adChannelService.editAdChannel(addChannel);
    }
}
